package org.jing.core.logger.log4j;

import org.apache.log4j.Level;
import org.apache.log4j.Priority;
import org.jing.core.logger.itf.JingLoggerLevelItf;
import org.jing.core.util.ClassUtil;

/**
 * Description: <br>
 *
 * @author bks <br>
 * @since 2021-08-16 <br>
 */
@SuppressWarnings({ "WeakerAccess", "SameParameterValue" })
public class LoggerLevel extends Level implements JingLoggerLevelItf {
    public static final LoggerLevel OFF = new LoggerLevel(Level.OFF);

    public static final LoggerLevel FATAL = new LoggerLevel(Level.FATAL);

    public static final LoggerLevel ERROR = new LoggerLevel(Level.ERROR);

    public static final LoggerLevel SQL = new LoggerLevel(39999, "SQL", 3);

    public static final LoggerLevel IMP = new LoggerLevel(39999, "IMP", 3);

    public static final LoggerLevel WARN = new LoggerLevel(Level.WARN);

    public static final LoggerLevel INFO = new LoggerLevel(Level.INFO);

    public static final LoggerLevel DEBUG = new LoggerLevel(Level.DEBUG);

    public static final LoggerLevel TRACE = new LoggerLevel(Level.TRACE);

    public static final LoggerLevel ALL = new LoggerLevel(Level.ALL);

    public static final LoggerLevel DEFAULT_LEVEL = DEBUG;

    private LoggerLevel(Level level) {
        super(
            (int) ClassUtil.getFieldValue(level, "level"),
            (String) ClassUtil.getFieldValue(level, "levelStr"),
            (int) ClassUtil.getFieldValue(level, "syslogEquivalent")
        );
    }

    private LoggerLevel(int level, String levelStr, int syslogEquivalent) {
        super(level, levelStr, syslogEquivalent);
    }

    @Override public boolean isGreaterOrEquals(JingLoggerLevelItf e) {
        return super.isGreaterOrEqual((Priority) e);
    }
}
